package com.wgo.bpot.server.servicewrapper;

import org.apache.log4j.Logger;

import com.wgo.bpot.domain.common.User;
import com.wgo.bpot.domain.common.UserCredential;
import com.wgo.bpot.domain.common.UserRole;
import com.wgo.bpot.domain.common.impl.UserImpl;
import com.wgo.bpot.server.service.RemoteServicesImpl;
import com.wgo.bpot.wiring.ServiceAccessor;
import com.wgo.bpot.wiring.WiringEngine;

public class DummyRemoteServices  extends RemoteServicesImpl {
	private static final Logger log = Logger.getLogger(DummyRemoteServices.class);
	private String correctUserName;
	private String correctPassword;
	private UserRole userRole;
	
	
	public DummyRemoteServices(WiringEngine<? extends ServiceAccessor> wiring, String correctUserName, String correctPassword, UserRole userRole) {
		super(wiring);
		this.correctUserName = correctUserName;
		this.correctPassword = correctPassword;
		this.userRole = userRole;
		init();
	}
	
	
	@Override
    protected User findUser(UserCredential userCredential) {
		if ((null!= userCredential) && userCredential.getUserName().equals(correctUserName)) {
			log.debug("Found user  '" + userCredential.getUserName() + "'");
			UserImpl user = new UserImpl();
			user.setUserName(correctUserName);
			user.setFirstName("first");
			user.setLastName("last");
			user.setPassword(correctPassword);
			user.setUserRole(userRole);
			return user;
		}
		log.debug("Did NOT find user");
		return null;
	}

	
}

